import React from 'react'
import {Modal,Toast} from "antd-mobile"
import {withRouter} from 'react-router-dom'

import './SharePopup.css'

import UrlIcon from "../../../../../res/images/web/game-room/url-icon.png"
import {copyToClip} from '../../../../../utils/copy'

// class
class SharePopup extends React.Component {


    render() {
        const {
            showSharePopup,
            hideSharePopup,
        } = this.props

        const shareList = [
            // {iconUrl: WechatIcon, title: '微信'},
            // {iconUrl: QQIcon, title: 'QQ'},
            {iconUrl: UrlIcon, title: '复制链接'},
        ]

        const shareTo = (title) => {
            if (title === '复制链接') {
                const href = window.location.href
                const copy = copyToClip(href)
                if (copy) {
                    Toast.info('复制成功')
                } else {
                    Toast.info('复制不成功 请手动复制')
                }
            } else if (title === '微信') {

            }

        }

        const sharePopupTemplate = (
            <Modal
                popup
                visible={showSharePopup}
                onClose={hideSharePopup}
                animationType="slide-up"
                className='test'
            >
                <div className='game-room-header-share-popup'>
                    <h4 className='game-room-header-share-popup-title'>转发至</h4>
                    <div className='game-room-header-share-popup-icons'>
                        {shareList.map(item => (
                            <div
                                key={item.title}
                                onClick={(e) => shareTo(item.title)}
                            >
                                <img src={item.iconUrl} alt=''/>
                                <p>{item.title}</p>
                            </div>
                        ))}
                    </div>
                </div>
            </Modal>
        )


        return sharePopupTemplate

    }
}

export default withRouter(SharePopup)
